// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial

import { MenuOverviewAdapter } from "menu_overview.slint";
import { Settings, SettingsAdapter } from "settings.slint";
import { Theme } from "../../theme.slint";

export { MenuOverviewAdapter, SettingsAdapter }

export global MenuPageAdapter {
    in property <[StandardListViewItem]> model: [
        { text: "Production & Self-consumption"},
        { text: "Usage"},
        { text: "Balance"},
        { text: "Weather"},
    ];
    in-out property <int> selected-index;
}

export component MenuPage {
    private property <bool> show-settings;

    callback page-changed(int /* index */);
    callback close;

    in-out property <int> current-index;

    Rectangle {
        x: -parent.width * current-index;
        width: 2 * parent.width;
        clip: true;

        if(current-index == 0) : Settings {
            width: root.width;

            close => {
                root.close();
            }
        }

        animate x { duration: Theme.durations.fast; }
    }

    function back() {
         current-index = 0;
    }
 }
